<!DOCTYPE HTML>
<html lang="zh">
<meta charset="utf-8">
<head>
    <link href="/aityWeb/static/favicon.ico" rel="stylesheet"/>
    <link href="/aityWeb/static/css/font-awesome.css" rel="stylesheet"/>

    <style type="text/css">
        .nav > li:hover .dropdown-menu {display: block;}
    </style>

    <link href="/aityWeb/static/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/aityWeb/static/css/font-awesome.css" rel="stylesheet"/>
    <!-- bootstrap-table 表格插件样式 -->
    <link href="/aityWeb/static/ajax/libs/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"/>
    <link href="/aityWeb/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.css" rel="stylesheet"/>
    <link href="/aityWeb/static/css/animate.css" rel="stylesheet"/>
    <link href="/aityWeb/static/css/style.css" rel="stylesheet"/>
    <link href="/aityWeb/static/css/checkbox.css" rel="stylesheet"/>
    <link href="/aityWeb/static/ajax/libs/select/select2.css" rel="stylesheet"/>
    <link href="/aityWeb/static/galaxy/css/ry-ui.css" rel="stylesheet"/>


</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info" style="padding-top: 10px;">
            <ul class="breadcrumb" style="font-size: 16px;background-color: #f3f3f3;padding: 5px 10px;color: #337ab7;">
                <li><i class="fa fa-home" aria-hidden="true"></i>&nbsp;&nbsp;<a href="#">首页</a></li>
                <li class="active"><a href="#">保证金管理</a></li>
            </ul>
            <div class="col-sm-12 " id="balance" name="balance"></div>
            <div class="col-sm-12 " style="padding-top: 10px;height: 100%">
                <form id="menu-form">
                    <div class="select-list">
                        <ul>
                            <li>
                                <input type="text" name="devName" placeholder="请输入关键字"/>
                            </li>
                            <li>
                            <input type="date" name="devName" placeholder="起始时间"/>
                            </li>
                            <li>
                                <input type="date" name="devName" placeholder="结束时间"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="btn-group hidden-xs" id="toolbar" role="group">
                <button onclick="bzjcz()" type="button" class="btn btn-primary">
                    <span class="glyphicon glyphicon-plus"></span>
                    保证金充值
                </button>

                <button type="button" class="btn btn-primary" style="margin-left: 10px;">
                    <span class="glyphicon glyphicon-download"></span>
                    导出excel
                </button>

            </div>
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>


<div class="modal fade" id="add_item_modal">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
								<h4 class="modal-title">存入保证金</h4>
							</div>
							<div class="modal-body">
								<form class="form-horizontal" id="add_item_form">
									<input name="id" id="couponsId" style="display: none;" />
									<div class="form-group">
										<label for="num" class="col-sm-3 control-label">存入的金额</label>
										<div class="col-sm-7">
											<input name="changesum" id="changesum" type="text" class="form-control" placeholder="请填写存入的金额" data-valid="required" data-tips="请填写存入的金额">
											<p class="text-warning" id="num_tips"></p>
										</div>
									</div>
									<div class="form-group">
										<label for="tempType" class="col-sm-3 control-label">类型</label>
										<div id="temp_list" class="col-sm-7">
											<label class="radio-inline"><input name="typename" type="radio" value="充值" >充值</label>
											<label class="radio-inline"><input name="typename" type="radio" value="支付宝转存" >支付宝转存</label>
											<label class="radio-inline"><input name="typename" type="radio" value="转入" >转入</label>
										</div>
									</div>
									<div class="form-group">
										<label for="remark" class="col-sm-3 control-label">备注</label>
										<div class="col-sm-7">
											<input name="remark" id="remark" type="text" class="form-control" placeholder="请填写备注">
										</div>
									</div>
								</form>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-default" id="item_close">关闭</button>
								<button type="button" class="btn btn-primary submit_item_btn" data-method="one" id="item_submit_save">保存</button>
							</div>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal-dialog -->
				</div>
<input type="hidden" name="pre_id" id="pre_id" />
<script src="/aityWeb/static/js/jquery.min.js"></script>
<script src="/aityWeb/static/js/bootstrap.min.js"></script>
<script src="/aityWeb/static/js/echarts.common.min.js"></script>

<!-- bootstrap-table 表格插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js"></script>
<!-- jquery-validate 表单验证插件 -->
<script src="/aityWeb/static/ajax/libs/validate/jquery.validate.min.js"></script>
<script src="/aityWeb/static/ajax/libs/validate/messages_zh.min.js"></script>
<script src="/aityWeb/static/ajax/libs/validate/jquery.validate.extend.js"></script>
<!-- jquery-validate 表单树插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
<!-- jquery-export 表格导出插件 -->
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js"></script>
<script src="/aityWeb/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js"></script>
<!-- 遮罩层 -->
<script src="/aityWeb/static/ajax/libs/blockUI/jquery.blockUI.js"></script>
<script src="/aityWeb/static/ajax/libs/layer/layer.min.js"></script>
<script src="/aityWeb/static/ajax/libs/layui/layui.js"></script>
<script src="/aityWeb/static/galaxy/js/common.js?v=2.3.0"></script>
<script src="/aityWeb/static/galaxy/js/ry-ui.js?v=2.3.0"></script>
	<script type="text/javascript" src="../../../../static/js/app/app.js"></script>
		<script type="text/javascript" src="../../../../static/js/cookies.js"></script>
	<script type="text/javascript" src="../../../../static/js/lib/MD5.js"></script>
	<script type="text/javascript" src="../../../../static/js/app/net.js"></script>
<script type="text/javascript">
   var re = GetRequest();
	var shop = re['shop'];
    //调试开关
	var debug_switch = true;
    var prefix = '';
      function loadInner(url) {
        window.location.href = "add.html";
      }
      
      
      
      
   jQuery(document).ready(function() {
   	
   initpro();
    

   });
   
   function bzjcz(){

   $('#add_item_modal').modal('show');
   }
   
   
   function dataTableInit(proid) {
         $("#bootstrap-table").bootstrapTable({
//          url: "../static/json/info.json",
//          createUrl: prefix + "/add",
//          updateUrl: prefix + "/edit/{id}",
//          removeUrl: prefix + "/remove",
//          search: false,
            modalName: "设备接地箱",
            url: "http://test.dongqil.com/qyd_dongqil/predeposit/selectPredeposititem",
            cache: false,
            method: 'post', 
            sortable: false, //是否启用排序
            pagination: true, //分页
            pageNumber:1,//初始化加载第一页，默认第一页
            pageSize: 10,
            pageList: [5,10, 25, 50],//可供选择的每页的行数（*）
            singleSelect: false,
//          showColumns: true,  //显示下拉框勾选要显示的列
            locale:"zh-US", //表格汉化
            search: false , //显示搜索框
            sidePagination: "server", //服务端处理分页server client
            //【查询设置】
            /* queryParamsType的默认值为 'limit' ,在默认情况下 传给服务端的参数为：offset,limit,sort
             设置为 ''  在这种情况下传给服务器的参数为：pageSize,pageNo */
            queryParamsType:'',
            queryParams: function queryParams(params) {
                     var param = {
                    data:{
                        page: params.pageNumber,
                        rows: params.pageSize,
                        type:"select",
                        predepositId:parseInt(proid)
                    },
                    checkcode:"",
                    type: 1//0 APP;1 后台
            };
             syslog(JSON.stringify(param));
                return param;
                
               },
               responseHandler: function(res) {
               	var tol=1;
               	var row=0;
               	  if(!!res.data){
                     tol=res.data.total;//总页数
                     row= res.data.rows;//数据
                     	}
                    return {
               		        
                    "total": parseInt(tol),//总页数
                       "rows": row  //数据
                     	
                 
                 };
              
       
               },
				columns: [{
					checkbox: true
				},
                {
                    field : 'id',
                    title : '设备ID'
                },
                {
                    field : 'type',
                    title : '类型'
                },
                {
                    field : 'oldsum',
                    title : '前余额'
                },
                {
                    field : 'changesum',
                    title : '发生额'
                },
                    {
                        field : 'newsum',
                        title : '后余额'
                    },
                    {
                        field : 'ordernumber',
                        title : '订单号'
                    },
                       {
                        field : 'opttime',
                        title : '发生时间'
                    },
                    {
                        field : 'remark',
                        title : '备注'
                                     
                    }]
        })
       }  
         function add(){
//       		$('[name="id"]').val("");
//	$('[name="shopname"]').val("");
//	$('[name="code"]').val("");
	$('[name="timeFrom"]').val("");
	$('[name="timeTo"]').val("");
	$('[name="num"]').val("");
//	$('[name="percount"]').val("");
//	$('[name="name"]').val("");
	$('[name="price"]').val("");
	$('[name="initprice"]').val("");
	$('[name="settleSum"]').val("");
         		$('#add_item_modal').modal('show');
         			$('#item_submit_save').attr('data-type','create');
//      $.loadInner.updateUrl("/aityWeb/view/clubManger/edit.html");
    }

    function  deletes(id) {
							//加载结算详情
							var info = {
								id: id,
								type: "delete"
							};
							doPost("shop/addSettletempitem",info,function(data){
									
								if(data.success){
									alert('删除成功');
									queryTemplate();
								}else if(data.code == 400){
									alert(data.desc);
								}
							});

				
       // $.loadInner.updateUrl("/aityWeb/view/venue/details/venue_detail.html");
        // $.loadInner.updateUrl("/aityWeb/view/venue/details/venue_upload.html");
//      $.loadInner.updateUrl("/aityWeb/view/venue/details/card.html");
    }
    	function syslog(strlog){
		if(debug_switch){
			console.log(strlog);
		}
	}


    function edit(id){
//  	e.preventDefault();
			$('#add_item_modal').modal('show');
			$('#item_submit_save').attr('data-type','edit');
//			var btn1 = document.getElementById('check_code_btn');
//			btn1.style.display = 'none';
//			document.getElementById('code').readOnly = true;
//			$('#examinesCode').slideDown('slow');
			//新增提交数据
			var info = {
				type:"wxselect",
				id: id
			};
			doPost("shop/addSettletempitem", info, function(data) {
				if(data.success) {
					var r = data.data;
					$('[name="id"]').val(r[0].id);
//					$('[name="shopname"]').val(r[0].shopname);
//					$('[name="shopid"]').val(r[0].shop);
//					$('[name="code"]').val(r[0].shopcode);
					$('[name="timeFrom"]').val(r[0].timefrom);
					$('[name="timeTo"]').val(r[0].timeto);
					$('[name="num"]').val(r[0].maxsalenum);
//					$('[name="percount"]').val(r[0].percount);
//					$('[name="name"]').val(r[0].couponname);
//					$('[name="usedNum"]').val(r[0].usednum);
//					$('[name="remainNum"]').val(r[0].remainnum);
					$('[name="price"]').val(r[0].saleprice);
					$('[name="initprice"]').val(r[0].price);
//					$('[name="daycount"]').val(r[0].daycount);
//					$('input[name="couponstype"][value="' + r[0].description + '"]').prop("checked", "checked");
					$('[name="settleSum"]').val(r[0].settlesum);
				} else if(data.code == 400) {
					alert(data.desc);
				}
			});
//      $.loadInner.updateUrl("/aityWeb/view/venue/detail/settlement/edit.html");
    }
    function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
        	var name = strs[i].split("=")[0];
        	var value = strs[i].split("=")[1];
            //theRequest[name]=unescape(value);
            theRequest[name]=decodeURI(value);
        }
   }
   return theRequest;
};

 function initpro() {
var r = GetRequest();
	var shop = parseInt(r['shop']);
	var shopid=0;
	   		if(!shop ){
	   			if(!Cookies.get("shopid") && Cookies.get("shopid") !=''){
	   				shop=0;
	   			}
	 shop = parseInt(Cookies.get("shopid"));
	  document.getElementById('toolbar').style.display="none";
	}

//	//查询本地数据
//	var sets = getSettings();
//	if(sets.isShopUser){
//		document.getElementById('page_close_btn').style.display = 'none';
//	}

	var info1 = {
		shopid: shop,
		type: 'select'
	};
	var str1 = '';
	//初始化场馆基础备用金信息
	doPost("predeposit/selectPredeposit", info1, function(data) {
		if(data.success) {
			var data = data.data;
  if(!!data){
  	$('[name="balance"]').html("<h1><font  color='red'>账户余额："+data[0].balance+"</font></h1>");
  	$("#pre_id").val(data[0].id);
  	  dataTableInit(data[0].id);
  }	
		}
	});
	}
 
 //提交存入
			$('#item_submit_save').click(function(e) {
				var r = GetRequest();
	              var shop = parseInt(r['shop']);
				var pre_id = parseInt($('#pre_id').val());
				//新增提交数据
				if(!pre_id){
							var info = {
					shopid: shop,
					type: "add"
				};
				doPost("predeposit/selectPredeposit", info, function(data) {
					if(data.success) {										
				     var info = {
					predepositId: data.data,
					typename: $('input[name="typename"]:checked').val(),
					remark: $('#remark').val(),
					changesum: $('#changesum').val(),
					type: "add"
				 };
				   doPost("predeposit/selectPredeposititem", info, function(data) {
					if(data.success) {
						alert('提交成功');
						window.history.go(0);
					} else if(data.code == 400) {
						alert(data.desc);
					}
		       });	
			} else if(data.code == 400) {
						alert(data.desc);
					}
				   });
				}else{
					var info = {
					predepositId: pre_id,
					typename: $('input[name="typename"]:checked').val(),
					remark: $('#remark').val(),
					changesum: $('#changesum').val(),
					type: "add"
				 };
				   doPost("predeposit/selectPredeposititem", info, function(data) {
					if(data.success) {
						alert('提交成功');
						window.history.go(0);
					} else if(data.code == 400) {
						alert(data.desc);
					}
		       });	
				}
	
			});
 
 		$('#item_close').click(function(e) {
				$('#add_item_modal').modal('hide');
			});
</script>
</body>
</html>

